<template>
    <div>
        <div class="header-info">
            <p>重置密码管理</p>
        </div>
        <div class="query">
            <kv label="姓名">
                <el-input v-model="query.name"></el-input>
            </kv>
            <kv label="手机">
                <el-input v-model="query.mobile"></el-input>
            </kv>
            <div>
                <el-button @click="query_click()">查询</el-button>
            </div>
        </div>
        <my-list ref="list" url="/user/resetPasswordList" :query="query" :page-size="20" @loaded="dataLoaded">
            <el-table-column
                    type="index"
                    width="50">
            </el-table-column>
            <el-table-column label="用户名">
                <template slot-scope="scope">
                    {{scope.row.loginName}}
                </template>
            </el-table-column>
            <el-table-column label="姓名">
                <template slot-scope="scope">
                    {{scope.row.name}}
                </template>
            </el-table-column>
            <el-table-column label="电话号码">
                <template slot-scope="scope">
                    {{scope.row.mobile}}
                </template>
            </el-table-column>
            <el-table-column label="员工号">
                <template slot-scope="scope">
                    {{scope.row.code}}
                </template>
            </el-table-column>
            <el-table-column label="利润中心">
                <template slot-scope="scope">
                    {{scope.row.LiRunZhongXin}}
                </template>
            </el-table-column>

            <el-table-column label="利润中心描述">
                <template slot-scope="scope">
                    {{scope.row.LiRunZhongXin_Name}}
                </template>
            </el-table-column>
            <el-table-column label="维护工厂">
                <template slot-scope="scope">
                    {{scope.row.WeiHuGongChang}}
                </template>
            </el-table-column>

            <el-table-column label="维护工厂描述">
                <template slot-scope="scope">
                    {{scope.row.WeiHuGongChang_Name}}
                </template>
            </el-table-column>
            <el-table-column label="是否负责人">
                <template slot-scope="scope">
                    {{scope.row.isManager_res}}
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <button @click="reset_click(scope.row)">重置密码</button>
                </template>
            </el-table-column>
        </my-list>
    </div>
</template>
<script>
    export default {
        name: "password",
        components: {},
        data() {
            return {
                query: {name: "", mobile: ""}
            };
        },
        mounted() {
            this.query_click();
        },
        methods: {
            query_click() {
                this.$refs["list"].doQuery();
            },
            dataLoaded(res, skip) {
                var json = res.data.data;
                json.forEach(it => {
                    jv.fillRes(it);
                })
            },
            reset_click(row) {
                var txt = "要重置【" + row.name + "】密码?";
                jv.confirm(txt).then( it => {
                    this.$http.post("/user/resetPassword", {userId: row.id}).then(res => {
                        jv.info("重置成功");
                        this.query_click();
                    });
                });
            }
        }
    };
</script>

